<template>
  <div>
    <tableComp
      :selectMap="selectMap"
      @getList="getList"
      :total="total"
      ref="tableComp"
      :labelWidth="120"
      :tableWidth="150"
      :tableData="tableData"
      :column="column"
    >
      <template slot="statusName" slot-scope="scope">
        <el-tag
          :type="
            scope.row.status == 1
              ? ''
              : scope.row.status == 2 || scope.row.status == 3
              ? 'success'
              : 'danger'
          "
          >{{ getStatus(scope.row.status) }}</el-tag
        >
      </template>
      <template slot="operate" slot-scope="scope">
        <el-button-group v-if="!(scope.row.status == 2 || scope.row.status == 4)">
          <el-button type="primary" @click="update(scope.row)">审核</el-button>
        </el-button-group>
      </template>
    </tableComp>
  </div>
</template>
  
  <script>
import {
  withdrawalPromoterList,
  withdrawalPass,
  withdrawalRefuse,
} from "@/api/promoter";
import customPage from "@/components/customPage";
export default {
  components: { customPage },
  props: ["shopname"],
  data() {
    return {
      tableData: [],
      total: 0,
      //1 待下单  2待审核 3已发货 4已结算  5审核不过
      statusList: [
        {
          label: "待下单",
          value: 1,
        },
        {
          label: "待审核",
          value: 2,
        },
        {
          label: "已发货",
          value: 3,
        },
        {
          label: "已结算",
          value: 4,
        },
        {
          label: "审核不过",
          value: 5,
        },
      ],
      selectMap: {
        trans_type: [],
      },
      column: [
        {
          label: "编号",
          prop: "id",
        },
        {
          label: "支付宝账户",
          prop: "payee_account",
        },
        {
          label: "收款人姓名",
          prop: "payee_name",
        },
        {
          label: "推广员姓名",
          prop: "name",
        },
        {
          label: "提现状态",
          slot: true,
          prop: "statusName",
        },
        {
          label: "提现金额",
          prop: "withdrawal_amount",
        },
        {
          label: "申请时间",
          prop: "apply_time",
        },
        {
          label: "到账时间",
          prop: "arrival_time",
        },
        {
          label: "审核时间",
          prop: "check_time",
        },
        {
          label: "操作人",
          prop: "admin_name",
        },
        {
          label: "原因",
          prop: "refuse_reason",
        },
        {
          label: "操作",
          slot: true,
          prop: "operate",
        },
      ],
    };
  },
  mounted() {
    this.$refs.tableComp.getList();
    // getTransList().then((res)=>{
    //   this.selectMap['trans_type'] = res.map((item)=>({
    //       name:item.name,
    //       code:item.trans_type
    //   }))
    //   console.log(this.selectMap)
    // })
  },
  methods: {
    getStatus(status) {
      let statusList = ["", "待审核", "已入账", "未入账", "提现拒绝"];
      return statusList[status];
    },
    getList({ flag, params }) {
      if (!flag) {
        this.tableData = [];
      }
      withdrawalPromoterList(params).then((res) => {
        this.tableData = res.list.data || [];
        this.total = res.list.total;
      });
    },
    update(row) {
      this.$confirm("您确定要审核通过吗?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "拒绝",
      })
        .then((res) => {
          if (res == "confirm") {
            withdrawalPass({
              id: row.id,
            }).then(() => {
              this.$refs.tableComp.getList();
            });
          }
          // delProduct({
          //   product_id: row.product_id,
          // }).then((res) => {
          //   this.$refs.tableComp.getList();
          // });
        })
        .catch(() => {
          withdrawalRefuse({
            id: row.id,
          }).then(() => {
            this.$refs.tableComp.getList();
          });
        });
    },
  },
};
</script>
  
  <style lang="scss" scoped>
</style>
  